import axios from "axios";
// import { getToken } from "./auth";

let service = axios.create({
    timeout: 5000,

});

// 请求拦截
service.interceptors.request.use(

    function(config) {
        console.log("su")
        // config.headers.authorization = "Bearer " + getToken();
        return config;
    },
    function(error) {
        console.log("error")
        // Do something with request error
        return Promise.reject(error);
    }
);
// 响应拦截
service.interceptors.response.use(
    response => {
        return response;
    },
    error => {
        if (error.response.status == 401) {
            window.location.href = "/login";
        }
        // if (error.response.status == 404) {
        //     window.location.href = "/404.html";
        // }
        return Promise.reject(error);
    }
    
);

export default service
